<template>
  <div class="mod-config">
    <basic-container>
      <navigationZDRW :sign="{ a: false, b: true, c: false }"></navigationZDRW>
      <div class="boxsty zhiBiao">
        <div :height="searchheight">
          <span
            style="float: right; margin-top: -30px; cursor: pointer"
            @click="searchchangeadvanced"
            >{{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
            <i
              :class="
                searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'
              "
            />
          </span>
          <div v-show="searchadvanced">
            <el-form
              :inline="true"
              :model="dataForm"
              @keyup.enter.native="getDataList()"
              class="form-inline"
            >
              <el-form-item label="任务书名称">
                <el-input
                  v-model="dataForm.workAssignName"
                  placeholder="任务书名称"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人姓名">
                <el-input
                  v-model="dataForm.ryName"
                  placeholder="被考核人姓名"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人岗位">
                <el-input
                  v-model="dataForm.userZw"
                  placeholder="被考核人岗位"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人职级">
                <el-input
                  style="width: 150px"
                  v-model="dataForm.userZj"
                  placeholder="被考核人职级"
                  :clearable="true"
                ></el-input>
              </el-form-item>
              <el-form-item label="任务书状态">
                <el-select
                  style="width: 150px"
                  v-model="dataForm.state"
                  placeholder="请选择"
                  clearable
                >
                  <el-option value="13" label="履约中"></el-option>
                  <el-option value="14" label="自评中"></el-option>
                  <el-option value="15" label="评价中"></el-option>
                  <el-option value="16" label="他评完成"></el-option>
                  <el-option value="17" label="结果汇总中"></el-option>
                  <el-option value="18" label="领导审核中"></el-option>
                  <el-option value="19" label="领导审核完成"></el-option>
                  <el-option value="20" label="审核结束"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-button
                  icon="el-icon-search"
                  type="primary"
                  class="marginLeft"
                  @click="getDataList(1)"
                  >检索
                </el-button>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div class="border-top-theme">
          <div class="mt10" style="overflow: hidden">
            <div style="float: right">
              <el-button type="primary" plain @click="sent()"
                >批量发起</el-button
              >
            </div>
          </div>
        </div>
        <el-table
          style="width: 100%; margin-top: 10px"
          :data="dataList"
          border
          ref="table"
          v-loading="dataListLoading"
        >
          <el-table-column
            type="selection"
            width="55"
            header-align="center"
            align="center"
          ></el-table-column>
          <el-table-column
            type="index"
            width="80"
            header-align="center"
            align="center"
            label="序号"
          ></el-table-column>
          <el-table-column
            prop="workAssignName"
            header-align="center"
            align="center"
            min-width="200"
            show-overflow-tooltip
            label="任务书名称"
          >
            <template slot-scope="scope">
              <span
                @click="preview(scope.row)"
                style="color: #0e258c; cursor: pointer"
                >{{ scope.row.workAssignName }}</span
              >
            </template>
          </el-table-column>
          <el-table-column
            prop="userName"
            header-align="center"
            align="center"
            min-width="120"
            show-overflow-tooltip
            label="被考核人编号"
          >
          </el-table-column>
          <el-table-column
            prop="ryName"
            header-align="center"
            align="center"
            min-width="120"
            show-overflow-tooltip
            label="被考核人姓名"
          >
          </el-table-column>
          <el-table-column
            prop="userDeptName"
            header-align="center"
            align="center"
            min-width="120"
            show-overflow-tooltip
            label="被考核人单位"
          >
          </el-table-column>
          <el-table-column
            prop="userZj"
            header-align="center"
            align="center"
            label="被考核人职级"
            min-width="180"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            prop="userZw"
            header-align="center"
            align="center"
            min-width="180"
            show-overflow-tooltip
            label="被考核人岗位"
          >
          </el-table-column>
          <el-table-column
            prop="indiNumbers"
            header-align="center"
            align="center"
            min-width="100"
            show-overflow-tooltip
            label="指标数量"
          >
          </el-table-column>
          <el-table-column
            prop="stateExplain"
            header-align="center"
            align="center"
            min-width="120"
            label="任务书状态"
          >
          </el-table-column>
        </el-table>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper"
          >
          </el-pagination>
        </div>
      </div>
      <fqcommon ref="fqcommon" @fqcommonchild="getDataList"></fqcommon>
    </basic-container>
  </div>
</template>

<script>
import { fetchList, sent } from "@/api/hetongrenwu/book/bookFq";
import fqcommon from "./editDailog";
export default {
  components: {
    fqcommon,
  },
  data() {
    return {
      dataForm: {},
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataList: [],
      dataListLoading: false,
      searchadvanced: true,
      searchheight: "0",
    };
  },
  created() {
    this.getDataList();
  },
  methods: {
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "auto";
      }
    },
    //预览
    preview(row) {
      this.$refs.fqcommon.init(row);
    },
    getDataList() {
      this.dataListLoading = true;
      fetchList(
        Object.assign(
          {
            current: this.pageIndex,
            size: this.pageSize,
          },
          this.dataForm
        )
      ).then((response) => {
        this.dataList = response.data.data.records;
        this.totalPage = response.data.data.total;
        this.dataListLoading = false;
      });
    },
    sent() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.warning("请勾选所提交的数据");
      } else {
        sent(data).then((res) => {
          if (res) {
            this.$message({
              type: "success",
              message: "发起成功!",
            });
            this.getDataList();
          } else {
            this.$message({
              type: "error",
              message: "发起失败!",
            });
          }
        });
      }
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
  },
};
</script>

<style>
</style>
